<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../../../assets/docs.css" rel="stylesheet" type="text/css" media="screen" />
<title>MooTools 1.3 Documentation - Utilities/Swiff</title>
</head>

<body>
  <div id="docs" class="doc">
    <div class="methods">
      <h4 class="menu-item"><a href="#Swiff">Swiff</a></h4>
      <div class="menu-item"><a href="#Swiff:remote">remote</a></div>
    </div>
    <div class="l-border r-border span-15 content">
      <h1 id="Swiff"><a href="#Swiff">Class: Swiff</a></h1>
      <p class="description">Creates and returns a Flash object using supplied parameters.</p>
      <h3>Credits:</h3>
      <p>Flash detection and Internet Explorer/Flash Player 9 fix adapted from <a href="http://blog.deconcept.com/swfobject/">SWFObject</a>.</p>
      <h3>Syntax:</h3>
      <pre class="javascript"><span class="kw2">var</span> mySwiff = <span class="kw2">new</span> Swiff<span class="br0">(</span>path<span class="br0">[</span>, options<span class="br0">]</span><span class="br0">)</span>;

</pre>
      <h3>Arguments:</h3>
      <ol>
        <li>path    - (<em>string</em>) The path to the SWF file.</li>
        <li>options - (<em>object</em>, optional) See Options below.</li>
      </ol>
      <h3>Options:</h3>
      <ul>
        <li>id - (<em>string</em>: defaults to 'Swiff_' + unique id) The id of the SWF object.</li>
        <li>width - (<em>number</em>: defaults to 1) The width of the SWF object.</li>
        <li>height - (<em>number</em>: defaults to 1) The height of the SWF object.</li>
        <li>container - (<em>element</em>) The container into which the SWF object will be injected.</li>
        <li>params - (<em>object</em>) Parameters to be passed to the SWF object (wmode, bgcolor, allowScriptAccess, loop, etc.).
          <ul>
            <li>allowScriptAccess - (<em>string</em>: defaults to always) The domain that the SWF object allows access to.</li>
            <li>quality - (<em>string</em>: defaults to 'high') The render quality of the movie.</li>
            <li>swLiveConnect - (<em>boolean</em>: defaults to true) the swLiveConnect parameter to allow remote scripting.</li>
            <li>wMode - (<em>string</em>: defaults to 'window') Changes the way the SWF is displayed in the browser.</li>
          </ul>
        </li>
        <li>properties - (<em>object</em>) Additional attributes for the object element.</li>
        <li>vars - (<em>object</em>) Vars will be passed to the SWF as querystring in flashVars.</li>
        <li>callBacks - (<em>object</em>) Functions to call from the SWF. These will be available globally in the movie, and bound to the object.</li>
      </ul>
      <h3>Returns:</h3>
      <ul>
        <li>(<em>element</em>) A new HTML object Element.</li>
      </ul>
      <h3>Example:</h3>
      <pre class="javascript"><span class="kw2">var</span> obj = <span class="kw2">new</span> Swiff<span class="br0">(</span><span class="st0">'myMovie.swf'</span>, <span class="br0">{</span>

    id: <span class="st0">'myBeautifulMovie'</span>,
    width: <span class="nu0">500</span>,
    height: <span class="nu0">400</span>,
    params: <span class="br0">{</span>
        wMode: <span class="st0">'opaque'</span>,
        bgcolor: <span class="st0">'#ff3300'</span>
    <span class="br0">}</span>,
    vars: <span class="br0">{</span>

        myVariable: myJsVar,
        myVariableString: <span class="st0">'hello'</span>
    <span class="br0">}</span>,
    callBacks: <span class="br0">{</span>
        load: myOnloadFunc
    <span class="br0">}</span>
<span class="br0">}</span><span class="br0">)</span>;
</pre>
      <h3>Note:</h3>
      <ol>
        <li>Although Swiff returns the object, this element will NOT have any Element methods applied to it.</li>
        <li>The $ function on an object/embed tag will only return its reference without further processing.</li>
        <li>Avoid changing the wMode param to 'transparent'. It will make your page more processor intensive, especially when running in a background tab.</li>
      </ol>
      <h2 id="Swiff:remote"><a href="#Swiff:remote">Swiff Function: remote</a></h2>
      <p class="description">Calls an ActionScript function from JavaScript.</p>
      <h3>Syntax:</h3>
      <pre class="javascript"><span class="kw2">var</span> result = Swiff.<span class="me1">remote</span><span class="br0">(</span>obj, fn<span class="br0">[</span>, arg, arg, arg ...<span class="br0">]</span><span class="br0">)</span>;
</pre>
      <h3>Arguments:</h3>
      <ol>
        <li>obj - (<em>element</em>) A Swiff instance (an HTML object Element).</li>
        <li>fn  - (<em>string</em>) The name of the function to execute in the Flash movie.</li>
        <li>arg - (<em>mixed</em>) Any number of arguments to pass to the named function.</li>
      </ol>
      <h3>Returns:</h3>
      <ul>
        <li>(<em>mixed</em>) The ActionScript function's result.</li>
      </ul>
      <h3>Example:</h3>
      <pre class="javascript"><span class="kw2">var</span> obj = <span class="kw2">new</span> Swiff<span class="br0">(</span><span class="st0">'myMovie.swf'</span><span class="br0">)</span>;

<span class="co1">// alerts "This is from the .swf file!".</span>
<span class="kw3">alert</span><span class="br0">(</span>Swiff.<span class="me1">remote</span><span class="br0">(</span>obj, <span class="st0">'myFlashFn'</span><span class="br0">)</span><span class="br0">)</span>;
</pre>
      <h3>Note:</h3>
      <p>The SWF file must be compiled with the ExternalInterface component.  See the Adobe documentation on <a href="http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&amp;file=00001652.html">External Interface</a> for more information.</p>
    </div>
  </div>
<script type="text/javascript" src="../../../assets/mootools-core-1.3.js"></script>
<script type="text/javascript" src="../../../assets/mootools-more-smoothscroll.js"></script>
<script type="text/javascript" src="../../../assets/doc-assist.js"></script>
</body>
</html>